import request from '@/axios'
import type { UserType } from './types'
import { SUCCESS_CODE } from '@/constants'

interface RoleParams {
  roleName: string
}

export const loginApi = (data): Promise<IResponse<UserType>> => {
  return request.post({ url: '/crm/login', data })
}

export const loginOutApi = (): Promise<IResponse> => {
  return request.post({ url: '/crm/logout' })
}

export const getAdminRoleApi = (params: RoleParams): { code: number; data: string } => {
  return {
    code: SUCCESS_CODE,
    data: 'roleName' === 'admin' ? 'adminList' : 'testList'
  }
  // return request.get({ url: '/mock/role/list', params })
}

export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
  return request.get({ url: '/mock/role/list2', params })
}
